package com.huage_08.lesson_05;

import java.io.*;
import java.net.Socket;

public class ClientTest {
    public static void main(String[] args) throws IOException {
        //创建客户端Socket对象
        Socket s = new Socket("192.168.56.1",1997);

        //上传文件
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        BufferedReader br = new BufferedReader(new FileReader("class1\\src\\com\\huage_08\\多线程与网络编程"));

        String line;
        while ((line=br.readLine())!=null){
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        s.shutdownOutput();

        //接收服务器反馈
        BufferedReader brServer = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String response = brServer.readLine();
        System.out.println("服务器响应:" + response);

        br.close();
        brServer.close();
        s.close();
    }
}
